home *** CD-ROM | disk | FTP | other *** search
/ BBS in a Box 11 / AMUG BBS in a Box Volume XI (April 1994) (MacWizards).iso / Files / Prog / B-C / C Servant™.sit / C Servant™.rsrc / TEXT_154_aText.txt < prev    next >
Encoding:
Text File  |  1992-02-23  |  645 b   |  13 lines

  1.  
  2. 27. Horrors! goto‚Äôs and labels
  3.  
  4.             C has a goto statement and labels, so you can branch about the way you used to. But most of the time goto‚Äôs aren‚Äôt needed. (How many have we used up to this point?) The code can almost always be more clearly expressed by for/while, if/else, and compound statements.
  5.  
  6.             One use of goto‚Äôs with some legitimacy is in a program which contains a long loop, where a while(1) would be too extended. Then you might write
  7.  
  8.             mainloop:
  9.                         ...
  10.                         goto mainloop;
  11.  
  12. Another use is to implement a break out of more than one level of for or while. goto‚Äôs can only branch to labels within the same function.
  13.